#pragma once
//boost log管理类，主要负责保存sink句柄，初始化以及程序结束时的句柄关闭

//日志相关
#include <boost/log/trivial.hpp>
#include <boost/log/core.hpp>
#include <boost/log/sources/global_logger_storage.hpp>
#include <boost/log/sources/logger.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/sources/record_ostream.hpp>
#include <boost/log/utility/setup/file.hpp>						//add_file_log
#include <boost/log/utility/setup/common_attributes.hpp>		//add_common_attributes
#include <boost/log/sinks/sync_frontend.hpp>
#include <boost/log/sinks/text_ostream_backend.hpp>				//text_ostream_backnd-->输出到文本
#include <boost/log/sinks/syslog_backend.hpp>					//syslog_backend
#include <boost/log/utility/value_ref.hpp>
#include <boost/log/support/date_time.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <fstream>
#include <boost/log/expressions.hpp>
#include <boost/log/attributes/scoped_attribute.hpp>
#include <boost/thread/thread.hpp>
#include <boost/throw_exception.hpp>
#include <vector>
#include <string>

//程序运行路径相关
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/core/null_deleter.hpp>
#include <boost/bind/bind.hpp>

namespace filesys = boost::filesystem;			//文件系统，目录
namespace logging = boost::log;
namespace src = boost::log::sources;
namespace sinks = boost::log::sinks;
namespace keywords = boost::log::keywords;
namespace trivials = boost::log::trivial;
namespace expr = boost::log::expressions;
namespace attrs = boost::log::attributes;

//最多保存几天的日志
const int MAX_BOOST_LOG_FILE_NUM = 60;

class CBoostLog
{
	typedef sinks::synchronous_sink<sinks::text_file_backend> file_sink;		//文件输出

public:
	CBoostLog();
	~CBoostLog();
	
	//初始化日志相关信息
	void InitLog(const std::string &log_root, const logging::formatter &fmt, unsigned int save_days = 60);

	//syslog初始化
	void InitSysLog();
	
	//停止日志系统
	void StopLog(void);
private://sink_forword句柄
	//流输出前端句柄，可以分流到多个后端
	//boost::shared_ptr<text_sink> sink_t;
	//文件输出句柄，1对1
	std::vector<boost::shared_ptr<file_sink>> vec_sink_f;
	//记录stoplog函数是否被调用过
	bool isStoped;
};